﻿// <copyright file="Infiltrator.cs" company="City of Portland, BES-ASM">
// </copyright>
// <summary>Infiltrator class</summary>

namespace BESASM.EMGAATS.BusinessClasses
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;

  /// <summary>
  /// Infiltrator: allows flow entering a node to bleed away from the system at a specified rate
  /// </summary>
  public class Infiltrator : Entity, IInfiltrator
  {
    /// <summary>
    /// Initializes a new instance of the <see cref="Infiltrator"/> class
    /// </summary>
    /// <param name="id">The ID of the Infiltrator</param>
    public Infiltrator(int id)
      : base(EntityType.Infiltrator, id)
    {
      this.InfiltratorName = string.Empty;
      this.Node = null;
    }

    /// <summary>
    /// Gets or sets the name of the Infiltrator
    /// </summary>
    public string InfiltratorName { get; set; }

    /// <summary>
    /// Gets or sets the node to which the Infiltrator belongs
    /// </summary>
    public INode Node { get; set; }

    /// <summary>
    /// Gets or sets the infiltration rate, in inches per hour
    /// </summary>
    public double RateInPerHr { get; set; }

    /// <summary>
    /// Gets or sets the area of infiltration, in square feet
    /// </summary>
    public double AreaSqFt { get; set; }

    /// <summary>
    /// Creates a new Infiltrator that is a copy of the current instance
    /// </summary>
    /// <returns>A new Infiltrator that is a shallow copy of this instance</returns>
    public override object Clone()
    {
      // Simple properties and references
      // DO NOT copy Network, clones must be added to a network
      Infiltrator clone = new Infiltrator(this.Id);

      clone.Node = this.Node;
      clone.InfiltratorName = this.InfiltratorName;
      clone.RateInPerHr = this.RateInPerHr;
      clone.AreaSqFt = this.AreaSqFt;

      this.CloneAuditProperties(clone);

      return clone;
    }

    /// <summary>
    /// Returns a string representation of this Infiltrator
    /// </summary>
    /// <returns>The string representation of this Infiltrator</returns>
    public override string ToString()
    {
      if (this.Node != null)
      {
        return string.Format("Inf{0}/{2} (N{1})", this.Id, this.Node, this.InfiltratorName);
      }
      else
      {
        return string.Format("Inf{0}/{1}", this.Id, this.InfiltratorName);
      }
    }
  }
}
